package com.myapp.struts.action;

import com.myapp.hibernate.model.Apuesta;
import com.myapp.hibernate.util.ApuestaUtil;
import com.myapp.struts.form.ApostarForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author jiglrom
 */
public class ActualizarApuestaAction extends org.apache.struts.action.Action {

    private static final String SUCCESS = "success";

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        ApostarForm formulario = (ApostarForm) form;
        ApuestaUtil apuestaUtil = new ApuestaUtil();
        Apuesta a = apuestaUtil.obtenerApuesta(formulario.getIdApuesta());
        a.setCantidad(formulario.getCantidad());
        a.setIdBoxeador(formulario.getIdBoxeador());
        apuestaUtil.actualizarApuesta(a);
        return mapping.findForward(SUCCESS);
    }
}
